const {
	db,
	dbCmd,
	result_success,
	result_error,
	appletInfoCollection,
	shopieCollection
} = require('../../common/constants')
module.exports = async function(params = {}) {
	const token = this.getUniIdToken()
	if (!token) {
		return result_error('登录失效,请重新登录')
	}
	let payload = await this.uniID.checkToken(token)
	if (payload.code) {
		return payload
	}
	let reconciliation = params.reconciliation
	if (!reconciliation) {
		return result_error('选择数据为空')
	}
	let report_start_time = reconciliation.split('至')[0]
	let report_end_time = reconciliation.split('至')[1]
	if(report_end_time.indexOf('当日')>-1){
		report_end_time=report_end_time.split('当日')[1]
	}else{
		report_end_time=report_end_time.split('次日')[1]
	}
	let appletInfoData = await appletInfoCollection.where({
		user_id: payload.uid
	}).update({
		report_start_time:report_start_time,
		report_end_time:report_end_time
	})
	return result_success()
}